import React from 'react';
import qs from 'query-string';
import cls from './print.module.scss';

interface IProps {
  label?: string;
  labelStyle?: React.CSSProperties;
  textStyle?: React.CSSProperties;
  children?: React.ReactNode;
  style?: any;
}

export default ({ label, style, children, labelStyle, textStyle }: IProps) => {
  const query = qs.parseUrl(window.location.href).query;

  return (
    <div style={style} className={`${query.pdf ? cls.printItemPdf : cls.printItem}`}>
      {label ? (
        <div style={labelStyle || {}}>{label}</div>
      ) : <div hidden />}
      <div style={textStyle || {}}>
        {children}
      </div>
    </div>
  );
};